﻿using System.Configuration;

namespace ExcelAutomator.Configuration.Internal
{
	internal class ParameterMappingCollection : ConfigurationElementCollection
	{
		public override ConfigurationElementCollectionType CollectionType
		{
			get
			{
				return ConfigurationElementCollectionType.AddRemoveClearMap;
			}
		}

		protected override ConfigurationElement CreateNewElement()
		{
			return new ParameterMappingElement();
		}

		protected override object GetElementKey(ConfigurationElement element)
		{
			var e = element as ParameterMappingElement;
			if (e != null)
			{
				return e.Id + e.AttributeName;
			}
			return element;
		}

		protected override void BaseAdd(ConfigurationElement element)
		{
			base.BaseAdd(element, false);
		}
	}
}
